<template>
  <a-drawer :width="500" :visible="show" :footer="false" @cancel="handleCancel" unmountOnClose>
    <template #title>
      {{data.type}}组件编辑
    </template>
    <div class="setting-content">
      <p class="item-title">背景颜色</p>
      <a-select v-model="data.bgColor" placeholder="请选择" allow-clear>
        <a-option value="#ffffff">白色</a-option>
        <a-option value="#F7F7FA">灰色</a-option>
      </a-select>

      <p class="item-title">间距设置</p>
      <a-select v-model="customSpace" placeholder="请选择" @change="handleChange" allow-clear>
        <a-option :value="1">制表符起始间距(49px,24px)</a-option>
        <a-option :value="2">部分间距(80px,40px)</a-option>
        <a-option :value="3">组件间距(32px,40px)</a-option>
        <a-option :value="4">链接间距(16px,16px)</a-option>
        <a-option :value="5">页末间距(160px,80px)</a-option>
      </a-select>

      <p class="item-title">PC高度（单位：px）</p>
      <a-input v-model="data.data.desktopHeight" disabled />

      <p class="item-title">移动端高度（单位：px）</p>
      <a-input v-model="data.data.mobileHeight" disabled />

      <p class="item-title">唯一标识</p>
      <a-input v-model="data.data.id" placeholder="请输入唯一标识" allow-clear />
    </div>
  </a-drawer>
</template>

<script lang="ts" setup>
import { ref } from 'vue'
const props = defineProps({
  show: {
    type: Boolean,
    default: false
  },

  data: {
    type: Object,
    default: () => {}
  }
})

const emit = defineEmits(['update:show']);
const handleCancel = () => {
  emit('update:show', false);
}

const customSpace = ref<number>(1);
const handleChange = (value: number) => {
  if (value === 1) {
    props.data.data.desktopHeight = 49;
    props.data.data.mobileHeight = 24;
  } else if (value === 2) {
    props.data.data.desktopHeight = 80;
    props.data.data.mobileHeight = 40;
  } else if (value === 3) {
    props.data.data.desktopHeight = 32;
    props.data.data.mobileHeight = 40;
  } else if (value === 4) {
    props.data.data.desktopHeight = 16;
    props.data.data.mobileHeight = 16;
  } else if (value === 5) {
    props.data.data.desktopHeight = 160;
    props.data.data.mobileHeight = 80;
  }
};
</script>

<style lang="scss" scoped>
.setting-content {
  position: relative;

  .item-title {
    padding: 12px 0 8px 0;
    font-size: 14px;
    font-weight: 600;
  }

  .item-img {
    margin-top: 12px;
    height: 160px;
  }
}
</style>